<include file="Public/header" />
<title>添加账册</title>
</head>
<body>
<div class="pd-20">
<form action="" name="postForm" id="postForm" method="post" >
<table class="table table-border table-bordered table-bg">
		<tbody>
		<tbody>
			<input type="hidden" name="warehouse_code" value="<{:I('warehouse_code')}>" >
			<input type="hidden" name="username" value="<{:I('username')}>" >
			<tr class="text-c">
				<td width="15%" class="text-r" style="background-color:#f5f5f5">订单编号</td>
				<td class="text-l" width="35%">
					<input type="text" readonly name="order_no" class="input-text" value="<{$serialNumber}>" >
				</td>
				<td width="15%" class="text-r" style="background-color:#f5f5f5">运单号</td>
				<td class="text-l">
					<input type="text" name="logistics_no" class="input-text" value="<{$detail.logistics_no}>" >
				</td>
			</tr>
			<tr class="text-c">	
				<td width="15%" class="text-r" style="background-color:#f5f5f5">收件人姓名</td>
				<td class="text-l" width="35%">
					<input type="text" name="user_name" class="input-text" value="<{$detail.user_name.name}>" >
				</td>
				<td width="15%" class="text-r" style="background-color:#f5f5f5">发件人姓名</td>
				<td class="text-l">
					<input type="text" name="sendMan" class="input-text"  value="<{$detail.sendMan.name}>" >
				</td>
			</tr>
			<tr class="text-c">	
				<td width="15%" class="text-r" style="background-color:#f5f5f5">收件人身份证号</td>
				<td class="text-l">
					<input type="text" name="user_idcard" class="input-text" value="<{$detail.user_name.no}>" >
				</td>
				<td width="15%" class="text-r" style="background-color:#f5f5f5"></td>
				<td class="text-l" width="35%">
					
				</td>
			</tr>
			<tr class="text-c">	
				<td width="15%" class="text-r" style="background-color:#f5f5f5">收件人电话(手机号)</td>
				<td class="text-l" width="35%">
					<input type="text" name="user_phone" class="input-text" value="<{$detail.user_name.tel}>" >
				</td>
				<td width="15%" class="text-r" style="background-color:#f5f5f5">发件人电话(手机号)</td>
				<td class="text-l">
					<input type="text" name="sendManPhone" class="input-text" value="<{$detail.sendMan.tel}>" >
				</td>
			</tr>
			<tr class="text-c">
				<td width="15%" class="text-r" style="background-color:#f5f5f5">收件人省</td>
				<td class="text-l">
					<select name="province" class="select input-text" style="width:250px;float:left;margin-right:5px;">
						<option value="0">---请选择---</option>
						<foreach name="province_list" item="vo">
							<option value="<{$vo['fullName']}>"<if condition="$vo['fullName'] eq $detail['user_name']['province']">selected</if> ><{$vo.fullName}></option>
						</foreach>
					</select>
				</td>
				<td width="15%" class="text-r" style="background-color:#f5f5f5">发件人省</td>
				<td class="text-l">
					<select name="sendProvince" class="select input-text" style="width:250px;float:left;margin-right:5px;">
						<option value="0">---请选择---</option>
						<foreach name="province_list" item="vo">
							<option value="<{$vo['fullName']}>"<if condition="$vo['fullName'] eq $detail['sendMan']['province']">selected</if> ><{$vo.fullName}></option>
						</foreach>
					</select>
				</td>
			</tr>
			<tr class="text-c">
				<td width="15%" class="text-r" style="background-color:#f5f5f5">收件人市</td>
				<td class="text-l" width="35%">
					<select name="city" class="select input-text" style="width:250px;float:left;margin-right:5px;">
						<option value="0">---请选择---</option>
						<foreach name="city_list" item="vo">
							<option value="<{$vo['fullName']}>"<if condition="$vo['fullName'] eq $detail['user_name']['city']">selected</if> ><{$vo.fullName}></option>
						</foreach>
					</select>
				</td>
				<td width="15%" class="text-r" style="background-color:#f5f5f5">发件人市</td>
				<td class="text-l">
					<select name="sendCity" class="select input-text" style="width:250px;float:left;margin-right:5px;">
						<option value="0">---请选择---</option>
						<foreach name="send_city_list" item="vo">
							<option value="<{$vo['fullName']}>"<if condition="$vo['fullName'] eq $detail['sendMan']['city']">selected</if> ><{$vo.fullName}></option>
						</foreach>
					</select>
				</td>
			</tr>
			<tr class="text-c">
				<td width="15%" class="text-r" style="background-color:#f5f5f5">收件人区/县</td>
				<td class="text-l">
					<select name="area" class="select input-text" style="width:250px;float:left;margin-right:5px;">
						<option value="0">---请选择---</option>
						<foreach name="area_list" item="vo">
							<option value="<{$vo['fullName']}>"<if condition="$vo['fullName'] eq $detail['user_name']['area']">selected</if> ><{$vo.fullName}></option>
						</foreach>
					</select>
				</td>
				<td width="15%" class="text-r" style="background-color:#f5f5f5">发件人区/县</td>
				<td class="text-l">
					<select name="sendCounty" class="select input-text" style="width:250px;float:left;margin-right:5px;">
						<option value="0">---请选择---</option>
						<foreach name="send_area_list" item="vo">
							<option value="<{$vo['fullName']}>"<if condition="$vo['fullName'] eq $detail['sendMan']['area']">selected</if> ><{$vo.fullName}></option>
						</foreach>
					</select>
				</td>
			</tr>
			<tr class="text-c">
				<td width="15%" class="text-r" style="background-color:#f5f5f5">收件人详细地址</td>
				<td class="text-l">
					<input type="text" name="user_address" class="input-text" value="<{$detail.user_name.address}>" >
				</td>
				<td width="15%" class="text-r" style="background-color:#f5f5f5">发件人详细地址</td>
				<td class="text-l">
					<input type="text" name="sendManAddress" class="input-text" value="<{$detail.sendMan.address}>" >
				</td>
			</tr>
			<tr class="text-c">
				<td width="15%" class="text-r" style="background-color:#f5f5f5">总价</td>
				<td class="text-l" width="35%">
					<input type="text" name="total_price" class="input-text" value="" >
				</td>				
				<td width="15%" class="text-r" style="background-color:#f5f5f5">状态</td>
				<td class="text-l" width="35%">
					<img src="__PUBLIC__/img/flag/flag_green.png">
					<input type="radio" name="flag" value="1" checked="">
					<img src="__PUBLIC__/img/flag/flag_yellow.png"></img>
					<input type="radio" name="flag" value="2">
					<img src="__PUBLIC__/img/flag/flag_red.png">
					<input type="radio" name="flag" value="3">
				</td>
			</tr>
			<tr class="text-c">
				<td width="15%" class="text-r" style="background-color:#f5f5f5">备注</td>
				<td class="text-l" width="35%">
					<textarea name="erp_mark_mailno" class="textarea" ><{$detail.erp_mark_mailno}></textarea>
				</td>
				<td width="15%" class="text-r" style="background-color:#f5f5f5">WMS备注</td>
				<td class="text-l" width="35%">
					<textarea name="mark_mailno" class="textarea" ><{$detail.mark_mailno}></textarea>
				</td>
			</tr>
		</tbody>
		</tbody>
	</table>

	<input type="button" class="btn btn-primary radius mt" id="b_add" value="更新">
</form>
</div>
<script type="text/javascript" src="__PUBLIC__/js/jquery.form.js"></script>
<script>
	$("#b_add").click(function() { 
        $("#postForm").ajaxSubmit({  
            url: "<{:U('add_orders')}>",
            type : "post",  
            dataType : 'json',  
            success : function(data) {
				if(data.status==1){
					layer.msg(data.message,function(){
						parent.window.location.href =parent.window.location.href;
					});
				}else{
					layer.msg(data.message);
				}
                
            },  
            error : function(data) {  
                layer.msg('出错');
            }  
        });  
    });
			$("select[name=province]").change(function(){
				$.ajax({
					type: 'POST',
					data: {code:$(this).val()},
					url: "<{:U('city_list')}>",
					success:function(data){
						<!-- console.log(data.message.length); -->
						if(data.status==1){
							$("select[name=city]").find('option').remove();
							$("select[name=area]").find('option').remove();
							$("select[name=area]").append("<option value='0'>---请选择---</option>");
							$("select[name=city]").append("<option value='0'>---请选择---</option>");
							for(i=0;i<data.message.length;i++){
								html="<option value='"+data.message[i].fullName+"'>"+data.message[i].fullName+"</option>";
								$("select[name=city]").append(html);
							}
						}else{			
							layer.msg(data.message);
						}
						return false;
					}
				})
			})
			$("select[name=city]").change(function(){
				province_name=$("select[name=province]").find('option:checked').val();
				$.ajax({
					type: 'POST',
					data: {province_name:province_name,code:$(this).val()},
					url: "<{:U('area_list')}>",
					success:function(data){
						if(data.status==1){
							$("select[name=area]").find('option').remove();
							$("select[name=area]").append("<option value='0'>---请选择---</option>");
							for(i=0;i<data.message.length;i++){
								html="<option value='"+data.message[i].fullName+"'>"+data.message[i].fullName+"</option>";
								$("select[name=area]").append(html);
							}
						}else{			
							layer.msg(data.message);
						}
						return false;
					}
				})
			})
			$("select[name=sendProvince]").change(function(){
				$.ajax({
					type: 'POST',
					data: {code:$(this).val()},
					url: "<{:U('city_list')}>",
					success:function(data){
						<!-- console.log(data.message.length); -->
						if(data.status==1){
							$("select[name=sendCity]").find('option').remove();
							$("select[name=sendCounty]").find('option').remove();
							$("select[name=sendCounty]").append("<option value='0'>---请选择---</option>");
							$("select[name=sendCity]").append("<option value='0'>---请选择---</option>");
							for(i=0;i<data.message.length;i++){
								html="<option value='"+data.message[i].fullName+"'>"+data.message[i].fullName+"</option>";
								$("select[name=sendCity]").append(html);
							}
						}else{			
							layer.msg(data.message);
						}
						return false;
					}
				})
			})
			$("select[name=sendCity]").change(function(){
				province_name=$("select[name=sendProvince]").find('option:checked').val();
				$.ajax({
					type: 'POST',
					data: {province_name:province_name,code:$(this).val()},
					url: "<{:U('area_list')}>",
					success:function(data){
						if(data.status==1){
							$("select[name=sendCounty]").find('option').remove();
							$("select[name=sendCounty]").append("<option value='0'>---请选择---</option>");
							for(i=0;i<data.message.length;i++){
								html="<option value='"+data.message[i].fullName+"'>"+data.message[i].fullName+"</option>";
								$("select[name=sendCounty]").append(html);
							}
						}else{			
							layer.msg(data.message);
						}
						return false;
					}
				})
			})
</script>
</body>
</html>